<template>
	<view>
		<view class="cu-modal bottom-modal" :class="showModal?'show':''" @tap="showModal=false">
			<view class="cu-dialog border-radius-top bg-gray minheight " @tap.stop="">
				<view class="absolute bg-gray round padding-xs right" @tap="showModal=false"><text class="cuIcon cuIcon-close"></text></view>
				<view class="text-bold text-black padding-tb bg-white">
					优惠
				</view>

				<view class="padding-bottom">
					<block v-for="(item,index) in list" :key="index" v-if="list">
						<couponView :value="item" :isGoods="true"></couponView>
					</block>
					<block v-else>
						<text class="empty">暂无优惠卷</text>
					</block>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import couponView from '@/components/shop/marketing/couponView.vue'
	export default {
		components: {
			couponView
		},
		props: {
			value: {
				type: Object,
				default: null
			},
		},
		filters: {
			mathTruePrice(value, discount) {
				return (parseFloat(value) * parseFloat(discount) / 100).toFixed(2)
			},
		},
		created: function(e) {
			this.now = new Date().getTime() / 1000
		},
		data() {
			return {
				now: 0,
				CLOUDPATH: this.$config.cloudPath,
				list: null,
				showModal: false
			}
		},
		methods: {
			setData(data) {
				this.list = data
			},
			show() {
				this.showModal = true
			},
			goCreate() {
				if (this.$common.loginAuth(true)) {
					this.$http
						.post('marketing_coupon_type_create', {
							id: this.value.id
						})
						.then((response) => {
							console.log(response)
						})
						.catch((response) => {})
				}
			},
		},
	}
</script>

<style>
	.minheight {
		min-height: 50vh;
	}

	.right {
		right: 20rpx;
		top: 20rpx;
	}
</style>
